<?php

namespace app\api\model;
use think\Model;
use think\facade\Db;
class DataUserCommission extends Common
{
    public function __construct(array $data = [])
    {
        parent::__construct($data);
        //  用户佣金表
        $this->table = 'data_user_commission';
    }
    public function getNum($searchWhere=[],$whereIn=[]){
         $query = Db::name($this->table)->where($searchWhere);
         foreach($whereIn as $k=>$v) {
             $query->whereIn($k, $v);
         }
         return $query->count();
    }
    public function getLists($searchWhere=[],$whereIn=[],$field='*',$group='',$order=[],$limit=[]){
         $query = Db::name($this->table)->where($searchWhere);
         foreach($whereIn as $k=>$v) {
             $query->whereIn($k, $v);
         }
         if(empty($group) === FALSE){
             $query = $query->group($group);
         }
         if(empty($order) === FALSE){
             $query = $query->order($order);
         }
         if(empty($limit) === FALSE){
             $query = $query->limit($limit[0],$limit[1]);
         }
         $res = $query->select();
         if(empty($res)){
             return [];
         }else{
             return $res->toArray();
         }
    }
}
